package com.oa.aop;

import com.oa.vo.SysResult;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author Administrator
 */
@Aspect
@Component
@Slf4j
public class ExceptionUtils {
    @Pointcut("@annotation(com.oa.aop.AspectException)")
    public void adminRequired() {
    }
    @AfterThrowing(pointcut = "com.oa.aop.ExceptionUtils.adminRequired()",throwing = "e")
    public SysResult afterThrowing(Throwable e){
        log.info("异常为: {}", e.getMessage());
        return SysResult.fail();
    }
}
